<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:replace="dashboard/header :: header"></head>
<body>
	<div layout:fragment="content">
		<div class="container-fluid content-main">
			<div class="animated fadeIn">
				<div class="row">
					<!-- /.col-->
					<div class="col-sm-12">
						<div class="card">
							<div class="card-body">

								<form class="form-horizontal" id="addForm">

									<input type="hidden" name="formToken" th:value="${session.formToken}" />
									
									<div class="form-group row">
										<label class="col-md-3 col-form-label" for="text-input">名称</label>
										<div class="col-md-9">
											<input class="form-control" id="text-input" type="text"
												name="applicationName" placeholder="应用名称">
										</div>
									</div>
									<div class="form-group row">
										<label class="col-md-3 col-form-label" for="email-input">描述</label>
										<div class="col-md-9">
											<input class="form-control" id="email-input" type="email"
												name="applicationDesc" placeholder="应用描述">
										</div>
									</div>
									<div class="form-group row">
										<label class="col-md-3 col-form-label" for="email-input">图标</label>
										<div class="col-md-9">
											<span class="form-control" id="applicationIconsLabel" style="cursor:pointer;" readonly="readonly" onclick="showIcons()">
												应用图标
											</span>
											<input type="hidden" id="applicationIcons" name="applicationIcons" />
										</div>
									</div>
									<div class="form-group row">
										<label class="col-md-3 col-form-label" for="email-input">状态</label>
										<div class="col-md-9">
											<select class="form-control" id="select1" name="select1">
												<option value="1" selected>启用</option>
												<option value="2">禁用</option>
											</select>
										</div>
									</div>
								</form>

							</div>

							<!-- 
							<div class="card-footer">
								<button class="btn btn-primary" style="float: right"
									onclick="save()" type="button">保存</button>
							</div>
							-->

						</div>
					</div>
					<!-- /.col-->
				</div>
			</div>
		</div>

	</div>

	<footer th:replace="dashboard/footer :: footer"></footer>

	<script type="text/javascript">
		
		function showIcons(){
			var index = layer.open({
			type : 2,
			title : false , //'菜单管理',
			closeBtn:0 ,
			shadeClose : true,
			shade : 0.8,
			area : [ '100%', '100%' ],
			content : ctx+'pages/boot/platform/application/icons?id=1' , 
			btn: ['确认', '取消'] , 
			yes: function(index, layero){
				
				console.log("index = " + index + " layero = " + layero) ; 
				var selectResourceParentNode = $(layero).find("iframe")[0].contentWindow.document.getElementById("selectResourceParentNode")
				
				var resourceName = $(selectResourceParentNode).attr("data-name") ; 	
				var id = $(selectResourceParentNode).attr("data-id") ; 	
				
				console.log("selectResourceId = " + id + " , selectResourceName = " + resourceName) ;
				
				$("span#applicationIconsLabel").html('<i class="'+resourceName+'" aria-hidden="true"></i>') ; 
				$("input#applicationIcons").val(id) ; 
				
				layer.close(index) ; 
				
			 }	
		   }) ; 
		} 
	
		function submitHandler() {
			$.operate.save(ctx+"boot/platform/application/save" , $('#addForm').serialize());
	    }

	</script>

</body>
</html>
